<template>
  <div>
    <Loading v-show="this.$store.state.isLoading" />
    <div class="container">
      <Swipe :banners="banners"></Swipe>
      <citySubNav :shortCut="shortCut" @triggeEvent="triggeEvent"></citySubNav>
      <List3 :obj="weekPopular" @gotoDetail="gotoDetail"></List3>
      <List1 :obj="newBook"></List1>
      <List4 :obj="reasoning" @gocontent="afterClick"></List4>
      <List2 :obj="boutique" @gotoContent="afterClick"></List2>
      <List4 :obj="historyCulture" @gotoContent="afterClick"></List4>
      <List1 :obj="inspiration"></List1>
      <List4 :obj="youthRomance" @gotoContent="afterClick"></List4>
      <!-- <List2 :obj="valuePack"></List2> -->
      <List2 :obj="qualityLife" @gotoContent="afterClick"></List2>
      <!-- <List2 :obj="learn"></List2> -->
    </div>
  </div>
</template>

<script>
import { getStoreData } from "@/request/api";
import Swipe from "@/components/swipe";
import citySubNav from "@/components/citySubNav";
import List1 from "@/components/List1";
import List2 from "@/components/List2";
import List3 from "@/components/List3";
import List4 from "@/components/List4";
export default {
  components: {
    Swipe,
    citySubNav,
    List1,
    List2,
    List3,
    List4,
  },
  data() {
    return {
      //广告
      banners: [],
      shortCut: [],

      //本周人气榜单
      weekPopular: {
        list: [],
        name: "",
        more: {
          name: "",
          url: "",
        },
      },
      //新书速递
      newBook: {
        list: [],
        name: "",
      },
      //悬疑推理
      reasoning: {
        list: [],
        name: "",
      },
      //精品小说
      boutique: {
        list: [],
        name: "",
      },
      //历史文化
      historyCulture: {
        list: [],
        name: "",
      },
      //经管励志
      inspiration: {
        list: [],
        name: "",
      },
      //青春言情
      youthRomance: {
        list: [],
        name: "",
      },
      //超值套装
      valuePack: {
        list: [],
        name: "",
      },
      //品质生活
      qualityLife: {
        list: [],
        name: "",
      },
      //学习充电
      learn: {
        list: [],
        name: "",
      },
    };
  },
  methods: {
    triggeEvent(arr) {
      let _url = arr[0];
      if (_url.indexOf("163.com") != -1) {
        window.location.href = _url;
        return;
      }
      let params = _url.split("?")[1];
      if (params.indexOf("&") == -1) {
        let param1 = params.split("=")[0];
        let p1 = params.split("=")[1];
        this.$router.push({
          name: "navcate",
          query: { params: p1, name: arr[1] },
        });
      } else {
        let p1 = params.split("&")[0].split("=")[1];
        let p2 = params.split("&")[1].split("=")[1];
        this.$router.push({
          name: "paihang",
          query: { uuid: p1, rankType: p2 },
        });
      }
    },
    afterClick(id) {
      this.$router.push("/content?source_uuid=" + id);
    },
    gotoDetail(id) {
      this.$router.push("/detail?sourceUuid=" + id);
    },
  },
  mounted() {
    getStoreData({
      type: this.$route.query.type,
      uuid: this.$route.query.uuid,
    }).then((res) => {
      if (res.resCode == 0) {
        let list = res.data.list;
        this.banners = list[0].banners;
        this.shortCut = list[1].shortCut;
        this.weekPopular = list[3];
        this.newBook = list[4];
        this.reasoning = list[5];
        this.boutique = list[6];
        this.historyCulture = list[7];

        this.inspiration = list[9];
        this.youthRomance = list[10];
        this.valuePack = list[11];
        this.qualityLife = list[12];
        this.learn = list[13];
      }
    });
  },
};
</script>

<style>
</style>